/**
 * User路由模块
 */

var express = require('express');
var router = express.Router();

const user = require("../controller/user");

const auth = require("../controller/auth");

router.post("/register", user.register);

router.post("/login", user.login);

router.get("/logout", auth.isLogin, user.logout);

router.patch("/change-info", auth.isLogin, user.changeInfo);

router.patch("/change-password", auth.isLogin, user.changePassword);

router.patch("/reset-password/:id", auth.isLogin, auth.isAdmin, user.resetPassword);

router.get("/count", auth.isLogin, auth.isAdmin, user.getCount);

router.get("/search", auth.isLogin, auth.isAdmin, user.search);

router.get("/:id", auth.isLogin, auth.isSelfOfAdmin, user.find);

router.get("/", auth.isLogin, auth.isAdmin, user.findAll);

router.post("/", auth.isLogin, auth.isAdmin, user.add);

router.put("/:id", auth.isLogin, auth.isAdmin, user.update);

router.delete("/:id", auth.isLogin, auth.isAdmin, user.remove);



module.exports = router;